#include	"vga.h"

static	ulong_t		vga_addr = 0, vga_size = 0;
static	int_t	vga_width_txt = 0, vga_height_txt = 0;
static	uint_t		vga_width_g = 0, vga_height_g = 0;
static	ushort_t	base_reg = 0;

void	vga_detect()
{
	if(in(MISC_REG_RDY) && 0x1)
	{
		vga_addr = 0xB8000;
		base_reg = 0x3D0;
	} else
	{
		vga_addr = 0xB0000;
		base_reg = 0x3B0;
	}

	vga_width_txt = *((ushort_t*)physical2virtual(0x44A));	// Área de dados do BIOS. 40:4A
	vga_height_txt = *((uchar_t*)physical2virtual(0x484));	// Área de dados do BIOS. 40:84
}

ulong_t	vga_address()
{
	return	vga_addr;
}

int_t	vga_width()
{
	return	vga_width_txt;
}

int_t	vga_height()
{
	return	vga_height_txt;
}

void	vga_set_cursor(int_t offset)
{
	out(base_reg + 4, 0xE);
	out(base_reg + 5, (offset >> 8) & 0xFF );
	out(base_reg + 4, 0xF);
	out(base_reg + 5, offset & 0xFF);	
}

